package test.deldumpinsortarr;

import java.util.Arrays;

public class Solution {
    public static void main(String[] args) {
        int[] nums = {1, 1, 2, 2, 7};
        //11227
        //12127
        System.out.println(new Solution().removeDuplicates(nums));
        System.out.println(Arrays.toString(nums));
    }

    public int removeDuplicates(int[] nums) {

        if (nums == null || nums.length == 0) {
            return 0;
        }
        int i=0;
        for (int j = 0; j < nums.length; j++) {
            if (nums[i] != nums[j]) {
                nums[i + 1] = nums[j];
                i++;
            }
        }
        return i + 1;
    }
}
